﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using O_D_EvaluationModel;
using DbHelper;

namespace O_D_EvaluationDAL
{
    public class UserInfoService
    {
        public static UserInfo GetUserInfo(UserInfo userInfo)
        {
            string sql = "select * from userinfo where username = @userName and password = @password";
            SqlParameter[] sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@userName", userInfo.UserName),
                new SqlParameter("@password", userInfo.Password)
            };
            UserInfo userInfo1 = new UserInfo();
            SqlDataReader sqlDataReader = DbHelperSQL.ExecuteReader(sql, sqlParameters);

            while (sqlDataReader.Read())
            {
                userInfo1.UserName = Convert.ToString(sqlDataReader["UserName"]);
                userInfo1.Password = Convert.ToString(sqlDataReader["Password"]);
                userInfo1.UserId = Convert.ToString(sqlDataReader["UserId"]);
                userInfo1.TrueName = Convert.ToString(sqlDataReader["TrueName"]);
            }
            sqlDataReader.Close();
            return userInfo1;
        }
    }
}
